package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.ChargeQuery;
import cn.wolfcode.crm.mapper.ChargeQueryMapper;
import cn.wolfcode.crm.query.ObjectQuery;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.service.IChargeQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ChargeQueryServiceImpl implements IChargeQueryService {
    @Autowired
    private ChargeQueryMapper chargeMapper;

    public void save(ChargeQuery record) {
        chargeMapper.insert(record);
    }

    public PageResult<ChargeQuery> query(ObjectQuery qo) {
        int totalCount = chargeMapper.queryForCount(qo);
        if (totalCount == 0) {
            return new PageResult<ChargeQuery>(totalCount, Collections.<ChargeQuery>emptyList());
        }
        return new PageResult<ChargeQuery>(totalCount, chargeMapper.queryForList(qo));
    }

    @Override
    public List<ChargeQuery> queryInsureInfoByClientId(Long clientId) {
        return chargeMapper.queryInsureInfoByClientId(clientId);
    }


}
